package renderer;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;

import world.Coordinator;

public class CoordinatorRenderer {
	public static void render(Coordinator cood) {
		// Bind to the VAO that has all the information about the vertices
		GL20.glEnableVertexAttribArray(0);
		GL20.glEnableVertexAttribArray(1);

		for (int i = 0; i < Coordinator.UNIT_ARRAY_SIZE; i++) {
			int vboId = GL15.glGenBuffers();
			GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);

			GL15.glBufferData(GL15.GL_ARRAY_BUFFER, cood.verticesBuffers[i], GL15.GL_STATIC_DRAW);

			GL20.glVertexAttribPointer(0, Coordinator.positionElementCount, GL11.GL_FLOAT, false, Coordinator.stride, Coordinator.positionByteOffset);
			GL20.glVertexAttribPointer(1, Coordinator.colorElementCount, GL11.GL_FLOAT, false, Coordinator.stride, Coordinator.colorByteOffset);
			GL11.glDrawArrays(GL11.GL_LINE_STRIP, 0,  Coordinator.AXIS_POINT_COUNT);

			GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
			GL15.glDeleteBuffers(vboId);// this is very important to release the
		}

		GL20.glDisableVertexAttribArray(0);
		GL20.glDisableVertexAttribArray(1);
	}
}
